import { PageConstant } from "@/common/Constant";
import router from "@/router";
import type { Response } from "@/typedefined/Response";
import { ElMessage } from "element-plus";
import { removeToken } from "./tokenUtils";

/**
 * @description 登录过期或未登录
 */
export function unLoginOrExpired() {
    ElMessage.error('登录已过期，请重新登录');
    removeToken();
    router.replace(PageConstant.LoginPage);
}

/**
 * @description 用户无权限
 */
export function userNoPermission(res:Response<any>) {
    if(res.data !== "用户无权限") return;
    removeToken();
    router.replace(PageConstant.LoginPage);
}